﻿@{
    Layout = "~/_SiteLayout.cshtml";

    Validation.RequireFields("oldpass", "newpass");
    
    if(IsPost && Validation.IsValid())
    {
        string oldpass = Request.Form["oldpass"];
        string newpass = Request.Form["newpass"];

        Business.Platform.Users busers = new Business.Platform.Users();

        var user = Business.Platform.Users.CurrentUser;
        if(user!=null)
        {
            if(string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(),oldpass.Trim()),false)!=0)
            {
                Business.Platform.Log.Add("修改密码失败",string.Concat("用户：",user.Name,"(",user.ID,")修改密码失败,旧密码错误!"), Business.Platform.Log.Types.用户登录);
                <script type="text/javascript">
                    alert("旧密码错误!");
                </script>
            }
            else
            {
                busers.UpdatePassword(newpass.Trim(), user.ID);
                Business.Platform.Log.Add("修改密码成功", string.Concat("用户：", user.Name, "(", user.ID, ")修改密码成功!"), Business.Platform.Log.Types.用户登录);
                <script type="text/javascript">
                    alert("密码修改成功!");
                    new RoadUI.Window().close();
                </script>
            }
        }
    }
    
}
<style type="text/css">
    body { overflow:hidden;}
</style>
<form method="post" action="">
<br />
    <table cellpadding="0" cellspacing="1" border="0" width="99%" class="formtable">
    <tr>
        <th style="width: 100px;">
            旧密码：
        </th>
        <td>
            <input type="password" name="oldpass" id="oldpass" class="mytext" value="" validate="empty" style="width: 55%" />
        </td>
    </tr>
    <tr>
        <th>
            新密码：
        </th>
        <td>
            <input type="password" name="newpass" id="newpass" class="mytext" value="" validate="empty" style="width: 55%"/>
        </td>
    </tr>
    <tr>
        <th>
            确认新密码：
        </th>
        <td>
            <input type="password" name="newpass1" id="newpass1" class="mytext" value="" validate="equal" validate_equalfor="newpass" errmsg="与新密码输入不一致" style="width: 55%"/>
        </td>
    </tr>
    </table>
    <div class="buttondiv">
        <input type="submit" value="确定保存" class="mybutton" onclick="return new RoadUI.Validate().validateForm(document.forms[0]);" />
        <input type="button" class="mybutton" value="取消关闭" style="margin-left: 5px;" onclick="new RoadUI.Window().close();" />
    </div>
</form>